﻿using System;
using System.Web;
using System.Web.Http;
using System.Web.Mvc;
using System.Web.Routing;

namespace Gym
{
    public class WebApiApplication : HttpApplication
    {
        /// <summary>
        /// 开启api的session功能
        /// </summary>
        public override void Init()
        {
            PostAuthenticateRequest += (sender, e) => HttpContext.Current.SetSessionStateBehavior(System.Web.SessionState.SessionStateBehavior.Required);
            base.Init();
        }
        protected void Application_Start()
        {
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            //BundleConfig.RegisterBundles(BundleTable.Bundles);
            //添加日志输出的配置
            log4net.Config.XmlConfigurator.ConfigureAndWatch(new System.IO.FileInfo(Common.Utils.GetMapPath("~/log4.config")));

        }
        protected void Application_Error(object obj, EventArgs e)
        {
            Exception objErr = Server.GetLastError().GetBaseException();
            Common.LogHelper.Info(objErr.Message);
        }
        protected void Application_End()
        {
            //关闭定时任务
           
        }
    }
}
